package com.secuenciafoto;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import com.camarasmactel.MenuPrincipal;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

public class ObtenerSecuencia extends Thread{

	String ruta="";
	
	public ObtenerSecuencia(){}
	
	public ObtenerSecuencia(String ruta){
		
		this.ruta = ruta;
	}
	
	public Bitmap bmImg;
	
//	String cadena = hcon.conexion;
	String cadena = "http://"+MenuPrincipal.dns+":"+MenuPrincipal.puerto+"/tmpfs/auto.jpg";
	
	@Override
	public void run() {
		// TODO Auto-generated method stub
	//	super.run();
		
		URL myFileUrl =null;  
		
	//	cadena = cadena+ruta;
		
	Log.i("Cadena", " "+cadena);	
		
        try {
             myFileUrl= new URL(cadena);
        } catch (MalformedURLException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
        }
        try {
            
        	        	
        	Log.i("Llega1", "llega 1 "+cadena);
      	   
        	HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
      	   
        	Log.i("Llega2", "llega 2");
      	   
        	conn.setDoInput(true);
      	   
        	Log.i("Llega3", "llega 3");
      	   
        	conn.connect();
      	   
        	Log.i("Llega4", "llega 4");
             
        	InputStream is = conn.getInputStream();
             
        	Log.i("Llega5", "llega 5");
            
        	bmImg  = BitmapFactory.decodeStream(is);
           
        	Log.i("Llega6", "llega 6");
        	
        	conn.disconnect();
        	
        	Log.i("Llega7", "llega 7");
        	
        } catch (IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
             Log.i("Llega9", "llega 9");
        }
         
	}

}
